<%@CODEPAGE="65001"%>
<script language="javascript" type="text/javascript" runat="server">
	function toObject(json) {	var o = eval('('+json+')');return o;}
	function addObj(o,attr,str){o[attr] = str;}
	function delObj(o,attr) {delete o[attr];}
	function isObj(o,attr){if(typeof(o[attr])!="undefined") return true;}
	function noObj(o,attr){if(typeof(o[attr])=="undefined") return true;}
	function toJSON(o){var json = "";for(attr in o) {json = json == "" ?  "'" + attr + "':'"+ String(o[attr]).replace(/(,)/g,"x@._a") + "'" : json + ",'" + attr + "':'" + String(o[attr]).replace(/(,)/g,"x@._a") + "'";}json = "{" + json + "}";json = "{" + json.match(/[^,\{]+(?=\}|,)/g).sort().join(",") + "}";json = json.replace(/(x@._a)/g,",");return  json ;}
	function toStr(o){var json = toJSON(o);var o = toObject(json);var str = "";for(attr in o) {str = str == "" ?  attr + "="+ o[attr] : str + "&" + attr + "="+ o[attr];}return str;}
	function toObject2(o) {var str = "";for(attr in o) {str = str == "" ? "name:'" + attr + "',value:'"+ o[attr] + "'" : str + "},{name:'" + attr + "',value:'" + o[attr] + "'";}str = "[{" + str + "}]";return toObject(str);}
	function getItem(obj,Num,Name){return obj[Num][Name];}
	function viewObject(obj){  var msg;for(var a in obj){  msg += ' ' + a;for(var x in obj[a]){msg += ' ' + x;msg += ' ' + obj[a][x];}}return msg;}
</script>
<%
'*******************************************************************************
'** PostHttp                                                                  **
'*******************************************************************************
Function PostHttpPage(PostUrl,PostData)
    Dim xmlHttp
    Dim RetStr      
    Set xmlHttp = CreateObject("Msxml2.ServerXMLHTTP")  
    xmlHttp.Open "POST", PostUrl, False
    XmlHTTP.setRequestHeader "Content-Length", Len(PostData)
    xmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded;charset=UTF-8"
    xmlHttp.Send PostData
    If Err.Number <> 0 Then
        Set xmlHttp=Nothing
        PostHttpPage = "$False$"
        Exit Function
    End If
    PostHttpPage=bytesToBSTR2(xmlHttp.responseBody,"utf-8")
    Set xmlHttp = nothing
End Function
Function BytesToBstr2(strBody,CodeBase)
       dim obj
       set obj=Server.CreateObject("Adodb.Stream")
       obj.Type=1
       obj.Mode=3
       obj.Open
       obj.Write strBody
       obj.Position=0
       obj.Type=2
       obj.Charset=CodeBase
       BytesToBstr2=obj.ReadText
       obj.Close
       set obj=nothing
End Function
Function getDate(var_date,var_format)
  if var_format="yyyy-mm-dd" Then
  'Right("0"&hour(published),2)
   var_year=year(var_date)
   var_month=month(var_date)
   var_day=day(var_date)
   if (var_month>=0 and var_month<=9) then
      var_month="0"&var_month  
   end if
  
   if (var_day>=0 and var_day<=9) then
       var_day="0"&var_day
   end if
    str_date=var_year&"-"&var_month&"-"&var_day
        getDate=str_date
  
  end if
End Function
Function getTime(var_time,var_format)
  if var_format="hh:mm:ss" then
    var_hour=hour(time)
        var_minute=minute(time)
        var_second=second (time)
        
        if (var_hour>=0 and var_hour<=9) then
             var_hour="0"&var_hour
        end if
        
        if (var_minute>=0 and var_minute<=9) then
             var_minute="0"&var_minute
        end if
        
        if (var_second>=0 and var_second<=9) then
             var_second="0"&var_second
        end if
        
        str_time=var_hour&":"&var_minute&":"&var_second
    getTime=str_time
  end if
End Function
Function strUrlEnCode(byVal strUrl)
	'GB2312用户请把下面两行的注释去掉
	'Session.CodePage=65001
	strUrlEnCode = Server.URLEncode(strUrl)
	strUrlEnCode = Replace(strUrlEnCode,"%5F","_")
	strUrlEnCode = Replace(strUrlEnCode,"%2E",".")
	strUrlEnCode = Replace(strUrlEnCode,"%2D","-")
	strUrlEnCode = Replace(strUrlEnCode,"+","%20")
	'Session.CodePage=936
End Function
Function GetHttpPage(HttpUrl)
  'response.write HttpUrl
     ' response.end
   If IsNull(HttpUrl)=True Or Len(HttpUrl)<10 Or HttpUrl="$False$" Then
      GetHttpPage=""
      Exit Function
   End If
   Dim Http
  'set Http= CreateObject("winhttp.winhttprequest.5.1")
   ' Set Http = CreateObject("Microsoft.XMLHTTP")
   Set Http=server.createobject("MSXML2.XMLHTTP")
  HttpUrl=Trim(HttpUrl)
   Http.open "GET",HttpUrl,False
   Http.Send()
   If Http.Readystate<>4 then
      Set Http=Nothing 
      GetHttpPage=""
      Exit function
   End If

   GetHTTPPage=bytesToBSTR(Http.responseBody,"UTF-8")

   Set Http=Nothing
   If Err.number<>0 then
      Err.Clear
   End If
End Function


Function BytesToBstr(Body,Cset)
   Dim Objstream
   Set Objstream = Server.CreateObject("adodb.stream")
   objstream.Type = 1
   objstream.Mode =3
   objstream.Open
   objstream.Write body
   objstream.Position = 0
   objstream.Type = 2
   objstream.Charset = Cset
   BytesToBstr = objstream.ReadText 
   objstream.Close
   set objstream = nothing
End Function
' main
apiurl = "https://readitlaterlist.com/v2/get"
apikey = "bdXpFF88A8by8W4795gT6f0g8cdUDq61"
username = "cheunglong"
password = "poor1985"
format = "json"
'DateDiff("s","01/01/1970 08:00:00",Now())
postdata = "username=" & username & "&password=" & password & "&apikey=" & apikey & "&format="& format & "&since=" & Now()'DateDiff("s","01/01/1970 08:00:00",Now())
'response.write apiurl & "?" & postdata
'response.end
'result = PostHttpPage(apiurl,strUrlEnCode(postdata))
result = GetHttpPage("http://baidu.com")
response.write result
response.end
resultHTML = resultHTML & "<ul class='list'>"
Set readlistJSON = TOOBJECT(result)
	For Each readlist In readlistJSON("list")
		resultHTML = resultHTML & "<li><a href='"&readlist.url&"'>" & readlist.title &"</a></li>"
		'resultHTML = resultHTML & "<li>" & Replace(searchResult.text,keyword,"<mark>"&keyword&"</mark>") & "</li>"
	Next
Set readlistJSON = nothing
resultHTML = resultHTML & "</ul>"
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>放屁社</title>
</head>
<body>
<div class="page">
	<div class="inner">
		<div class="header">
			<h1 class="logo"><a href=""><span class="hide-clip">放屁社</span></a></h1>
		</div>
		<div class="mainer">
			<div class="result"><%=resultHTML%></div>
		</div>
		<div class="footer"><address class="copyright">&copy; 2010-2011 fang.pe</address></div>
	</div>
</div>
</body>
</html>